const babelCore = require('@babel/core')

const code = `
  let obj = {
    a: { first: 'Miss' },
    b: { second: 'Lucy' }
  }
  function test(x = "hello", { a, b }, ...args) {
    console.log(x, a, b, args);
  }

  test(undefined, obj, 'how', 'are', 'you')
`
const result = babelCore.transformSync(code, {
  plugins: ["@babel/plugin-transform-parameters"]
})

console.log(result.code);